package com.sunther.document.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sunther.document.dao.FileMidDao;
import com.sunther.document.entity.FileMidEntity;
import com.sunther.document.service.FileMidService;
import org.springframework.stereotype.Service;
import springfox.documentation.annotations.Cacheable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author csb
 * @description: TODO
 * @date 2023/5/24 11:25
 */
@Service
public class FileMidServiceImpl extends ServiceImpl<FileMidDao, FileMidEntity> implements FileMidService {

    @Override
    public Map<String, String> getNameMapByIds(List<String> ids) {
        Map<String, String> map = new HashMap<>();
        if (ids.size() > 0) {
            QueryWrapper<FileMidEntity> wrapper = new QueryWrapper<>();
            wrapper.in("id",ids);
            List<FileMidEntity> list = list(wrapper);
            map = list.stream().collect(Collectors.toMap(FileMidEntity::getId, FileMidEntity::getName));
        }
        return map;
    }
}
